package yyy.ab.modules.quartz.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.ToString;
import yyy.ab.common.utils.DateUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.Map;

/**
 * quartz封装实体类
 */
@Builder(toBuilder = true)
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class QuartzJobInfo implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 需要执行的任务类型(针对不同的项目，可以自己定义对应的类型)
     */
    private byte type;
    /**
     * 任务标题（作为参数进行存储）
     */
    private String jobTitle;

    /**
     * 任务执行类名(全限定名)
     */
    private String jobClassName;
    /**
     * 任务名称
     */
    private String jobName;

    /**
     * 任务组名称
     */
    private String jobGroupName;

    /**
     * 触发器名称
     */
    private String triggerName;

    /**
     * 触发器组名
     */
    private String triggerGroupName;

    /**
     * 触发器状态
     */
    private String triggerState;

    /**
     * 任务所需参数
     */
//    private Map<String, Object> params;
    private String parameter;

    /**
     * cron表达式
     */
    private String cronExpresstion;

    /**
     * 触发时间
     */
    private Date fireDate;

    /**
     * 备注
     */
    private String description;

    public byte getType() {
        return type;
    }

    public void setType(byte type) {
        this.type = type;
    }

    public String getJobClassName() {
        return jobClassName;
    }

    public void setJobClassName(String jobClassName) {
        this.jobClassName = jobClassName;
    }

    public String getJobName() {
        return jobName;
    }

    public void setJobName(String jobName) {
        this.jobName = jobName;
    }

    public String getJobGroupName() {
        return jobGroupName;
    }

    public void setJobGroupName(String jobGroupName) {
        this.jobGroupName = jobGroupName;
    }

    public String getTriggerName() {
        return triggerName;
    }

    public void setTriggerName(String triggerName) {
        this.triggerName = triggerName;
    }

    public String getTriggerGroupName() {
        return triggerGroupName;
    }

    public void setTriggerGroupName(String triggerGroupName) {
        this.triggerGroupName = triggerGroupName;
    }

    public String getJobTitle() {
        return jobTitle;
    }

    public void setJobTitle(String jobTitle) {
        this.jobTitle = jobTitle;
    }

    public String getParameter() {
        return parameter;
    }

    public void setParameter(String parameter) {
        this.parameter = parameter;
    }

    public String getCronExpress() {
        return cronExpresstion;
    }

    public void setCronExpress(String cronExpresstion) {
        this.cronExpresstion = cronExpresstion;
    }

    public Date getFireDate() {
        return fireDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getCronExpresstion() {
        return cronExpresstion;
    }

    public void setCronExpresstion(String cronExpresstion) {
        this.cronExpresstion = cronExpresstion;
    }

    public String getTriggerState() {
        return triggerState;
    }

    public void setTriggerState(String triggerState) {
        this.triggerState = triggerState;
    }

    public void setFireDate(Date fireDate) {
        this.fireDate = fireDate;
        //将日期转换为Cron表达式
        this.setCronExpress(DateUtils.getCronExpression(fireDate));
    }

}
